import { createRouter, createWebHistory } from 'vue-router'
import type { RouteRecordRaw } from "vue-router";


const routes: Array<RouteRecordRaw> = [
  {
    path: "/",
    name: "yin-container",
    component: () => import("@/views/YinContainer.vue"),
    children: [
      {
        path: "/",
        name: "home",
        component: () => import("@/views/Home.vue"),
      },       
      {
        path: "/search",
        name: "search",
        component: () => import("@/views/search/Search.vue"),
      }, 
      {
        // 登录页面路由
        // 用户登录入口，验证用户身份
        path: "/sign-in",
        name: "sign-in",
        component: () => import("@/views/SignIn.vue"), // 懒加载登录组件
      }, 
      {
        // 注册页面路由
        // 新用户注册入口，创建新的用户账户
        path: "/sign-up",
        name: "sign-up",
        component: () => import("@/views/SignUp.vue"), // 懒加载注册组件
      },
      {
        // 个人中心页面路由
        path: "/personal",
        name: "personal",
        meta: {
          requireAuth: true,
        },
        component: () => import("@/views/personal/Personal.vue"),
      },
      {
        path: "/setting",
        name: "setting",
        meta: {
          requireAuth: true,
        },
        component: () => import("@/views/setting/Setting.vue"),
        children: [
          {
            path: "/setting/PersonalData",
            name: "personalData",
            meta: {
              requireAuth: true,
            },
            component: () => import("@/views/setting/PersonalData.vue"),
          }
        ]
      },
      {
        path: "/song-sheet",
        name: "song-sheet",
        component: () => import("@/views/song-sheet/SongSheet.vue")
      },
      {
        path: "/song-sheet-detail/:id",
        name: "song-sheet-detail",
        component: () => import("@/views/song-sheet/SongSheetDetail.vue")
      }
    ]
  }
]
const router = createRouter({
  history: createWebHistory(),
  routes
})

export default router
